#!/usr/bin/perl

#====  PROJECT =================================================================
#         NAME:  Lattice
#      PURPOSE:  Test Case for a simple lattice network.
#      RETURNS:  True
#===============================================================================


# Initialisation: Simple Lattice Network.

use insj_m_network;

use structures::lattice;

# Create the network.
	$network = initialize_lattice({'x' => 32, 'y' => 32});

# Infect a single node.
	$node = $network->get_node( "4;4" );
	$node -> set_state("VirusA", 1,1); $node -> set_state("VirusA_t", 1,1);

# Evolve network, transmission probability 10%.
	for($generation = 2; $generation <=250; $generation++){
		$network->rewind;
		
		while ( $node = $network -> get_next ){
			
			$node->rewind;

			while ( $edge = $node -> get_next ){
				#The Ruleset.
				if ( $edge -> get_state("VirusA") == 1 ) {
					if ( rand(100) <= 50 and $node->get_state("VirusA") == 0) { $node->set_state("VirusA_t", 1, $generation); 
						}
					}
				}
			}
		# Temporay states to actual states!
		$network->rewind;
		
		while ( $node = $network -> get_next ){
			if ( $node->get_state("VirusA") != $node->get_state("VirusA_t") ) { 
				$node->set_state("VirusA", $node->get_state("VirusA_t"), $generation);  
				}			
			}

		
	}
$network->print;

$network->export("test_lattice.gexf", "gephi");

1;

